home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4862 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.3 KB  |  41 lines

  1. Path: sislnews.csc.ti.com!not-for-mail
  2. From: ramli@sislnews.csc.ti.com (C. S. Ramalingam)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Unable to check calloc`s
  5. Date: 7 Feb 1996 08:41:29 -0600
  6. Organization: Texas Instruments
  7. Message-ID: <4fadmp$t6g@osage.csc.ti.com>
  8. References: <4f2l8a$c98@gail.ripco.com>
  9. NNTP-Posting-Host: osage.csc.ti.com
  10.  
  11.       In article <4f2l8a$c98@gail.ripco.com>,
  12.       Martin Ambuhl <mambuhl@ripco.com> wrote:
  13.       s910500@acs.csc.cuhk.hk (CHAN CHUN CHUNG)
  14.       in <4emept$ifv@hpg30a.csc.cuhk.hk> asks:
  15.             
  16.            [deleted]
  17.       
  18.       4) calloc zeros out memory.  This does not mean that pointers are set to
  19.           NULL or that floating values are set to a value of floating point
  20.           zero.  It is also true that this is frequently wasted effort even
  21.           for integral values.  malloc() is usually what you want:
  22.           #include <stdlib.h>
  23.           {
  24.               float **x;
  25.               if (x = malloc(9*sizeof(float *))) == 0)
  26.                   exit(EXIT_FAILURE);
  27.           }
  28.  
  29. When would using calloc be more appropriate than using malloc ?  Is it true
  30. that the only use for calloc is in initializing integral values to zero ?
  31. If so, why was a new function, which appears to have very limited used,
  32. introduced in the first place ?
  33.  
  34.  
  35. Thanks.
  36.  
  37. ramli.
  38.  
  39.  
  40.  
  41.